<?php
namespace app\index\controller;
use think\Db;
use think\Session;
use think\Controller;
use think\Request;
class Product extends controller
{
	public function index(){
		$zero_column=Db::name('column')->select();
        $this->view->assign('zero_column', $zero_column);
		$this->view->assign('Assets', Assets);
		return $this->view->fetch();
	}
	public function addess(){
		$zero_addesss=Db::name('product')->where('class',41)->select();
		$zero_column=Db::name('column')->select();
        $this->view->assign('zero_column', $zero_column);
        $this->view->assign('zero_addesss', $zero_addesss);
        $this->view->assign('Assets', Assets);
        return $this->view->fetch();
    }
	public function plist(){

		$website=website();

	    $total=Db::name('product')->count();//总数据量
		$class=input('class');//当前栏目
		$page=input('page',1);//当前页数
		$num=$website['pro_list_page'];//一页显示的数量
		$start=$num*($page-1);//开始条数
		
		$product=Db::name('product');
		$where['class']=$class;
		$data=$product->where($where)->limit($start,$num)->order('id desc')->select();//总数据
		$data_page=$product->where($where)->paginate($num,false,['query'=>request()->param(),]);//分页
		$zero_column=Db::name('column')->select();
        
		//数据处理，把imglist的第一张图片分出来赋值给imgurl
		foreach ($data as $k => $v) {
			$img=explode('|',$v['imglist']);
			$data[$k]['imgurl']=$img[0];
		}

		//渲染
		$this->view->assign('zero_column', $zero_column);
		$this->view->assign('data',$data);
		$this->view->assign('data_page',$data_page);
        $this->view->assign('total',$total);
		$this->view->assign('Assets', Assets);
		return $this->view->fetch();
	}
/**	
	public function data()
    {
       $start = Input('post.start');
       //echo($start);
       $list = db('product')->limit($start, 5)->order('product asc')->select(); 
       return (array( 'result'=>$list,'status'=>1, 'msg'=>'获取成功！'));
    }
**/	
	public function proinfo(){
		$id=$_GET['id'];
       	$proinfo=db('product')->where('id',$id)->find();
		$imglist=$proinfo[imglist];
		$pieces=explode("|",$imglist);
		$zero_column=Db::name('column')->select();
        //var_dump($apps);
        $this->view->assign('zero_column', $zero_column);
		$this->view->assign('pieces',$pieces);
        $this->view->assign('proinfo',$proinfo);
		$this->view->assign('Assets', Assets);
		return $this->view->fetch();
	}

	
}